package com.wondertek.poms.dao.repo;

import com.wondertek.poms.dao.po.Content;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import sun.awt.SunHints;

import java.util.List;

/**
 * <p><b>IcontentDao Description:</b> Dao 执行的查询、修改、新增、删除操作</p>
 * <p>@author 窦再兴</p>
 * <p><b>DATE</b> 2020-10-21 17:28:27</p>
 */
@Repository
public interface IContentDao extends JpaRepository<Content, Long> {

	
	Content findByContentId(String contentId);

	@Query(value="SELECT listagg(to_char(pi.name),',') within GROUP (order by to_char(pi.name)) " +
			"FROM prd_info pi " +
			"WHERE EXISTS " +
			"(SELECT 1 FROM prd_cont pc WHERE pc.is_delete = 0 AND pc.content_id = ?1 AND pc.prd_info_id = pi.prdinfoid) " +
			"and (pi.system_flag=2 or pi.system_flag is null)", nativeQuery = true)
	List<String> findPrdInfoByContent(String contentId);

	@Query(value = "select detail from Content where contentId = ?1")
	String findDetailByContentId(String contentid);
}
